package com.ruoyi.service.check.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.enums.YesNoEnum;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.service.check.entity.CheckRecordEntity;
import com.ruoyi.service.check.mapper.CheckRecordMapper;
import com.ruoyi.service.check.query.CheckRecordQuery;
import com.ruoyi.service.check.service.CheckRecordService;
import java.util.List;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 审核记录表 服务实现类
 * </p>
 *
 * @author Zane
 * @since 2025-10-30
 */
@Service
public class CheckRecordServiceImpl extends ServiceImpl<CheckRecordMapper, CheckRecordEntity>
    implements CheckRecordService {

  @Override
  public List<CheckRecordEntity> listRecord(CheckRecordQuery query) {
    final LambdaQueryWrapper<CheckRecordEntity> queryWrapper = effectQuery().orderByDesc(
        CheckRecordEntity::getId);
    if (StringUtils.isNotBlank(query.getSearchKey())) {
      queryWrapper.like(CheckRecordEntity::getCheckRemark, query.getSearchKey());
    }
    return list(queryWrapper);
  }

  private LambdaQueryWrapper<CheckRecordEntity> effectQuery() {
    return new LambdaQueryWrapper<CheckRecordEntity>()
        .eq(CheckRecordEntity::getDelFlag, YesNoEnum.NO.getCode());
  }
}
